const key = 'TOKEN'
const setToken = (token: string): void => {
  localStorage.setItem(key, token)
}
const getToken = (): string | null => {
  // console.log(typeof localStorage.getItem(key))
  if (typeof localStorage.getItem(key) === 'string') {
    return localStorage.getItem(key)
  }
  return null
}
const removeToken = (): void => {
  localStorage.removeItem(key)
}
// 判断是否已经登录 是否有token (鉴权) 场景：可以判断一个值是否为空 !! 可以将值转变为对应的 boolean 值
const isToken = (): boolean => !!getToken()
export { setToken, getToken, removeToken, isToken }